import Taro from '@tarojs/taro'
const { rpc, fromNowOn } = require('../../utils/util.js')
const service = require('./service.js')
const regeneratorRuntime = require('../../utils/async.js')
const app = (module.exports = {})

app.wxlogin = async (params, action, state) => {
  const data = await rpc(service.wxlogin, params)
  const { is_admin, token } = data
  const { userInfo = {} } = Taro.getApp().globalData

  Taro.getApp().globalData.userInfo = { ...userInfo, is_admin }
  Taro.getApp().globalData.token = token
}
